package Leetcode第一期;

/**
 * @author : K k
 * @date : 19:36 2020/9/15
 */
public class 滑动窗口的最大值_59_I {
    public int[] maxSlidingWindow(int[] nums, int k) {


        if (nums.length <= 1) {return nums;}

        int[] res = new int[nums.length - k + 1];
        for (int i = 0; i < nums.length - k; i++) {
            int max = -Integer.MAX_VALUE;
            for (int j = 0; j < k; j++) {
                if (nums[i + j] > max) {
                    max = nums[i + j];
                }
            }
            res[i] = max;
        }
        return res;
    }

}
